package demo;


import lombok.Getter;

/**
 * @description:
 * @author: feixiang.li
 * @date: 2025-07-08 17:46
 */
@Getter
public enum AgeEnum {

    ONE(1, "one"),
    TWO(2, "two"),
    THREE(3, "three"),
    FOUR(4, "four"),
    FIVE(5, "five"),
    SIX(6, "six"),
    SEVEN(7, "seven"),
    EIGHT(8, "eight"),
    ;
    private final int code;
    private final String name;

    AgeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameByIndex(Integer index) {
        for (AgeEnum value : AgeEnum.values()) {
            if (value.code == index) {
                return value.name;
            }
        }
        return null;
    }
}
